package iblink.adapter.request;

import java.util.Date;

import com.ib.client.Contract;

import iblink.adapter.IBClient;
import iblink.core.ISecurity;
import iblink.core.ScannerArgs;
import iblink.util.Constants.BarSize;
import iblink.util.Constants.DataType;
import iblink.util.Constants.Duration;
import packutil.idgen.IIdGenerator;

public class RequestFactory implements IRequestFactory {

	private IBClient ibClient;
	private IIdGenerator requestIdGenerator;

	public RequestFactory(IBClient ibClient, IIdGenerator requestIdGenerator) {
		this.ibClient = ibClient;
		this.requestIdGenerator = requestIdGenerator;
	}

	public HistoricalDataRequest createHistoricalDataRequest(ISecurity sec,
			Date endDateTime, Duration duration, BarSize barSize,
			DataType whatToShow, boolean onlyRegularTradingHours) {
		return new HistoricalDataRequest(ibClient, requestIdGenerator, sec,
				endDateTime, duration, barSize, whatToShow,
				onlyRegularTradingHours);
	}

	public ScannerDataRequest createScannerDataRequest(ScannerArgs scannerArgs) {
		return new ScannerDataRequest(ibClient, requestIdGenerator, scannerArgs);
	}

	public ContractDetailsRequest createContractDetailsRequest(Contract contract) {
		return new ContractDetailsRequest(ibClient, requestIdGenerator,
				contract);
	}
}
